#/bin/bash
HOME="/home"
HTOP_URL="http://hisham.hm/htop/releases/2.2.0/htop-2.2.0.tar.gz"
if [ ! -d "$HOME" ]; then
    mkdir $HOME
fi

rpm -q ncurses-devel &>/dev/null
if [ $? -ne 0 ]; then
    yum -y install make ncurses-devel
fi
rpm -q wget &>/dev/null
if [ $? -ne 0 ]; then
    yum -y install make wget
fi
rpm -q tar &>/dev/null
if [ $? -ne 0 ]; then
    yum -y install make tar
fi

cd $HOME
wget -c $HTOP_URL
tar zxvf htop-2.2.0.tar.gz
cd htop-2.2.0
./configure && make && make install

if [ $? -ne 0 ]; then
    echo "make或make install失败"
    exit
else
    echo "make成功"
fi
